package com.zt.teacher.controller;

import com.zt.common.pojo.common.JsonResult;
import com.zt.common.pojo.exam.Exam;
import com.zt.teacher.dto.ExamSummaryDTO;
import com.zt.teacher.dto.SummaryDTO;
import com.zt.teacher.service.ExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * description:
 * author:zt
 * date:2022-01-17
 */
@RestController
@CrossOrigin
@RequestMapping("exam")
@Api("考试模块")
public class ExamController {

    @Autowired
    private ExamService examService;

    @PostMapping("addExam")
    @ApiOperation("发布考试")
    public JsonResult<Integer> addExam(@RequestBody Exam exam){
        int examId = examService.insert(exam);
        return JsonResult.success(examId);
    }

    @GetMapping("getSummary/{classId}")
    @ApiOperation("获取该班级的所有考试平均分")
    public JsonResult<ArrayList<ExamSummaryDTO>> gerSummaryByClassId(@PathVariable int classId){
        return JsonResult.success(examService.getExamSituation(classId));
    }
}
